Add GTK_ALIGN_BASELINE to GtkAlign
authorAlexander Larsson <alexl@redhat.com>
Tue, 5 Mar 2013 14:06:12 +0000 (15:06 +0100)
committerAlexander Larsson <alexl@redhat.com>
Tue, 23 Apr 2013 03:47:31 +0000 (05:47 +0200)
Setting this means baseline aware containers should align the widget
according to the baseline. For other containers this behaves like
FILL.

In order to not suprise old code with a new enum value we always
return _FILL for _BASELINE unless you specifically request it via
gtk_widget_get_valign_with_baseline().

gtk/gtkenums.h
gtk/gtkwidget.c
gtk/gtkwidget.h

index 1789d98c4101ccea74bd00038d00aa0339d8e9fe..9df69a89d5341e506d2893839996aff5a5b52f49 100644 (file)
@@ -51,6 +51,7 @@ G_BEGIN_DECLS
  *     or top
  * @GTK_ALIGN_CENTER: center natural width of widget inside the
  *     allocation
+ * @GTK_ALIGN_BASELINE: align the widget according to the baseline. Since 3.10.
  *
  * Controls how a widget deals with extra space in a single (x or y)
  * dimension.
@@ -64,13 +65,18 @@ G_BEGIN_DECLS
  *
  * Note that in horizontal context @GTK_ALIGN_START and @GTK_ALIGN_END
  * are interpreted relative to text direction.
+ *
+ * GTK_ALIGN_BASELINE support for it is optional for containers and widgets, and
+ * it is only supported for vertical alignment.  When its not supported by
+ * a child or a container it is treated as @GTK_ALIGN_FILL.
  */
 typedef enum
 {
   GTK_ALIGN_FILL,
   GTK_ALIGN_START,
   GTK_ALIGN_END,
-  GTK_ALIGN_CENTER
+  GTK_ALIGN_CENTER,
+  GTK_ALIGN_BASELINE
 } GtkAlign;
 
 
index 0ce66b6a03fe16fe15ed5baeb6b41657c051284c..d1c9095bc101bb290f453e390e64329f02060b12 100644 (file)
@@ -5721,6 +5721,7 @@ adjust_for_align (GtkAlign  align,
 {
   switch (align)
     {
+    case GTK_ALIGN_BASELINE:
     case GTK_ALIGN_FILL:
       /* change nothing */
       break;
@@ -13518,6 +13519,13 @@ gtk_widget_set_halign (GtkWidget *widget,
   g_object_notify (G_OBJECT (widget), "halign");
 }
 
+GtkAlign
+gtk_widget_get_valign_with_baseline (GtkWidget *widget)
+{
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
+  return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
+}
+
 /**
  * gtk_widget_get_valign:
  * @widget: a #GtkWidget
@@ -13529,8 +13537,12 @@ gtk_widget_set_halign (GtkWidget *widget,
 GtkAlign
 gtk_widget_get_valign (GtkWidget *widget)
 {
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
-  return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
+  GtkAlign align;
+
+  align = gtk_widget_get_valign_with_baseline (widget);
+  if (align == GTK_ALIGN_BASELINE)
+    return GTK_ALIGN_FILL;
+  return align;
 }
 
 /**
index 3d57ddeb5a289d3aaeb839d9ccc3dd6d7998201f..97e9f7afdc5511a1f737e9baa00f6a90602d66ee 100644 (file)
@@ -760,6 +760,7 @@ GtkAlign gtk_widget_get_halign        (GtkWidget *widget);
 void     gtk_widget_set_halign        (GtkWidget *widget,
                                        GtkAlign   align);
 GtkAlign gtk_widget_get_valign        (GtkWidget *widget);
+GtkAlign gtk_widget_get_valign_with_baseline (GtkWidget *widget);
 void     gtk_widget_set_valign        (GtkWidget *widget,
                                        GtkAlign   align);
 gint     gtk_widget_get_margin_left   (GtkWidget *widget);